﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DTO;

namespace DAO
{
     public class Search_DAO
    {
        public DataProvider _provider = new DataProvider();
        public Search_DAO()
        {
            _provider.connect();
        }
        public DataTable GetCmdXe()
        {
            string s = "Select * from LoaiSP where PhanBiet = 1 ";
            return _provider.executeQuery(s);
        }
        public DataTable GetCmdLoaiNL()
        {
            string s = "Select * from LoaiSP where PhanBiet = 3";
            return _provider.executeQuery(s);
        }
        public DataTable GetBtnSearchNL(int MaLoaiNL, int MaLoaiSP)
        {
            string s = "select TenNLG, SoLuong from NLG where MaLoaiSP = " + MaLoaiSP + " and MaLoaiNLG = " + MaLoaiNL ;                  
            return _provider.executeQuery(s);
        }
        public DataTable GetBtnSearchTP(int MaLoaiSP)
        {
            string s = "select TenTP, SoLuong from ThanhPham where MaLoaiTP = " + MaLoaiSP;
            return _provider.executeQuery(s);
        }
        public DataTable GetBtnXemTheoSL(int SoLuong)
        {
            string s = "select NLG.TenNLG, NLG.SoLuong, ThanhPham.TenTP, ThanhPham.SoLuong from "
                       + "NLG, ThanhPham "
                       + "where NLG.SoLuong <= " + SoLuong + "and ThanhPham.SoLuong <= " + SoLuong;
            return _provider.executeQuery(s);
        }
    }
}
